/**
 入驻小区
 **/
(function (vc) {
    var DEFAULT_PAGE = 1;
    var DEFAULT_ROWS = 10;
    vc.extends({
        data: {
            aRoomDetailOwnerInfo: {
                owners: [],
                roomId: '',
            }
        },
        _initMethod: function () {
        },
        _initEvent: function () {
            vc.on('aRoomDetailOwner', 'switch', function (_data) {
                $that.aRoomDetailOwnerInfo.roomId = _data.roomId;
                $that._loadARoomDetailOwnerData(DEFAULT_PAGE, DEFAULT_ROWS);
            });
            vc.on('aRoomDetailOwner', 'notify',
                function (_data) {
                    $that._loadARoomDetailOwnerData(DEFAULT_PAGE, DEFAULT_ROWS);
                });
            vc.on('aRoomDetailOwner', 'paginationPlus', 'page_event',
                function (_currentPage) {
                    $that._loadARoomDetailOwnerData(_currentPage, DEFAULT_ROWS);
                });
        },
        methods: {
            _loadARoomDetailOwnerData: function (_page, _row) {
                let param = {
                    params: {
                        roomId: $that.aRoomDetailOwnerInfo.roomId,
                        ownerTypeCd: '1001',
                        page: _page,
                        row: _row
                    }
                };

                //发送get请求
                vc.http.apiGet('/owner.queryAdminRoomOwner',
                    param,
                    function (json) {
                        let _roomInfo = JSON.parse(json);
                        $that.aRoomDetailOwnerInfo.owners = _roomInfo.data;
                        vc.emit('aRoomDetailOwner', 'paginationPlus', 'init', {
                            total: _roomInfo.records,
                            dataCount: _roomInfo.total,
                            currentPage: _page
                        });
                    },
                    function () {
                        console.log('请求失败处理');
                    }
                );
            },
            //查询
            _qureyARoomDetailOwner: function () {
                $that._loadARoomDetailOwnerData(DEFAULT_PAGE, DEFAULT_ROWS);
            },
        
           
            _viewOwnerFace: function (_url) {
                vc.emit('viewImage', 'showImage', {
                    url: _url
                });
            },
            _toARoomDetailOwnerDetail:function(_owner){
                window.open('/#/pages/owner/adminOwnerDetail?ownerId='+_owner.ownerId);
            }
        }
    });
})(window.vc);